package com.isoft.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "app.watch")
public class AppWatchConfig {
    private String directory = "D:/xml_watch_directory";
    private String filePattern = ".*\\.xml$";
    private int maxThreads = 3;
    private int stabilityChecks = 5;
    private long checkIntervalMs = 500;
    private long eventCooldownMs = 2000;

    // 添加文件锁等待时间配置（单位：毫秒）
    private long fileLockWaitMs =3000; // 默认3秒

    public long getFileLockWaitMs() {
        return fileLockWaitMs;
    }

    public void setFileLockWaitMs(long fileLockWaitMs) {
        this.fileLockWaitMs = fileLockWaitMs;
    }

    // Getters  Setters
    public String getDirectory() {
        return directory;
    }
    public void setDirectory(String directory) {
        this.directory = directory;
    }
    public String getFilePattern() {
        return filePattern;
    }
    public void setFilePattern(String filePattern) {
        this.filePattern = filePattern;
    }
    public int getMaxThreads() {
        return maxThreads;
    }
    public void setMaxThreads(int maxThreads) {
        this.maxThreads = Math.max(1, maxThreads);
    }
    public int getStabilityChecks() {
        return stabilityChecks;
    }
    public void setStabilityChecks(int stabilityChecks) {
        this.stabilityChecks = Math.max(1, stabilityChecks);
    }
    public long getCheckIntervalMs() {
        return checkIntervalMs;
    }
    public void setCheckIntervalMs(long checkIntervalMs) {
        this.checkIntervalMs = Math.max(100, checkIntervalMs);
    }
    public long getEventCooldownMs() {
        return eventCooldownMs;
    }
    public void setEventCooldownMs(long eventCooldownMs) {
        this.eventCooldownMs = Math.max(500, eventCooldownMs);
    }
}